package com.bugsnag.ohos;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * FileUtil
 *
 * @since 2021-07-02
 */
public class FileUtil {
    private FileUtil() {
    }

    /**
     * is input file
     *
     * @param file
     * @param strResponse
     * @return boolean
     */
    public static boolean inputFile(File file, String strResponse) {
        boolean isInputFile = false;
        FileOutputStream fop;
        try {
            fop = new FileOutputStream(file);
            if (!file.exists()) {
                boolean isSuccess = file.createNewFile();
                if (! isSuccess) {

                }
            }
            byte[] contentInBytes = strResponse.getBytes("UTF-8");
            fop.write(contentInBytes);
            fop.flush();
            fop.close();
            isInputFile = true;
        } catch (IOException e) {
            e.getMessage();
        }
        return isInputFile;
    }
}
